<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>left-right-frame</title>

    <style>
        .container-fluid{
            padding:15px 0;
        }
        .bg-gray{
            background-color:#eee;
        }
    </style>

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-2" id="left-nav">
            <ul class="nav nav-pills nav-stacked"></ul>
        </div>
        <div class="col-sm-10" id="right-content"></div>
    </div>
</div>

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.2.4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script>
    $('#right-content').css('height',$(window).height()-30);
</script>

<!--渲染列表-->
<script>
    //导航数据
    var NAV_DATA=[
        {
            url:'https://baidu.com',
            text:'nav',
        },
        {
            url:'https://baidu.com',
            text:'nav',
        },
        {
            url:'https://baidu.com',
            text:'nav',
        },
        {
            url:'https://baidu.com',
            text:'nav',
        },
        {
            url:'https://baidu.com',
            text:'nav',
        },
    ];

    if(NAV_DATA.length){
        let list=[];
        for(let i=0,len=NAV_DATA.length;i<len;i++){
            list.push('<li data-hash="index-'+i+'"><a name="index-'+i+'" href="'+NAV_DATA[i]['url']+'" target="right-content">#'+i+'&ensp;'+NAV_DATA[i]['text']+'</a></li>');
        }

        $('#left-nav ul').html(list.join(''));
    }
</script>

<!--路由位置-->
<script>
    if(location.hash&&location.hash.length){
        let hash=location.hash.replace(/^[#]+/,'');
        let item=$('#left-nav ul li[data-hash='+hash+']');
        item.addClass('bg-gray');

        let index=item.index();
        if(index>-1){
            $('#right-content').html('<iframe src="'+NAV_DATA[index]['url']+'" name="right-content" width="100%" height="100%" frameborder="0"></iframe>');
        }
    }

    $('#left-nav ul li').click(function(){
        $('#left-nav ul li').removeClass('bg-gray');
        $(this).addClass('bg-gray');

        location.hash='#'+$(this).attr('data-hash');
    })
</script>
</body>
</html>